<%@ page contentType="text/html; charset=utf-8" %>
<%@ page import="cn.lily.com.configure.util.ESBSetting"%>

<script>
//window.bodyHeight = $(window).height() - 120;
window.bodyHeight = $(window).height() - 80;
window.portalPath = "/lily";

window.pwMenu = "";                    //菜单标示
window.pwAppCode = "";                 //访问系统标示
window.pwCtxPath = "";                 //访问系统部署
window.pwAppPath = "";                 //访问系统路径
window.pwMenuPath = "";                //访问菜单路径

window.portalAppPath = {};
window.portalMenuPath = {};

if($(window).height()>=700){
	$("body").addClass("mid");
}else{
	$("body").removeClass("mid");
}

$.ajax({
	
    type: "POST",
    url: Yacon.getRootPath()+"/portalService?commID=application&winH="+$(window).height(),
    processData: false,
    async: false,
    dataType: 'text', 
    success: function(data){ 	
  	  
  	 var rsp = JSON.parse(data);
  	 
  	 window.ske = rsp.ske.decode();
  	 
  	 //单应用模式
  	 if(rsp.singleAppID){
  		 
  		 var html = "";
  		 
  		 html += "<li class='layui-nav-item sysmenu' style='display:none;'>";
  		 html += "<a href='javascript:;'>单应用</a>"; 		 
  		 html += "<dl class='layui-nav-child'>";
  		 
  		 html += "<dd>"; 
		 html += "<a href='javascript:;' sid='0' appd-id='"+rsp.singleAppID+"'>"+rsp.singleAppID+"</a>"; 
		 html += "</dd>";
		 html += "</dl>";
	  	 html += "</li>"; 
	  	 
	  	$("#portal-system").append(html);
  		 
  		 
  	 }else{
  		 
  	  	 var html = "";
  	  	 
  	  	 var idx = 0;
  	  	 
  	  	 for(var i=0;i<rsp.infos.length;i++){
  	  		 
  	  		 html += "<li class='layui-nav-item sysmenu'>";
  	  		 html += "<a href='javascript:;'>"+rsp.infos[i].typeNam+"</a>";
  	  		 
  	  		 html += "<dl class='layui-nav-child'>";
  	  		 
  	  		 var apps = rsp.infos[i].apps; 		 
  	  		 for(var j=0;j<apps.length;j++){
  	  			html += "<dd>"; 
  	  			html += "<a href='javascript:;' sid='"+idx+"' appd-id='"+apps[j].appCode+"'>"+apps[j].appName+"</a>"; 
  	  			html += "</dd>"; 
  	  			
  	  			idx++;
  	  		 }
  	  		 	 
  	  		 html += "</dl>";
  	  		 html += "</li>";   		 
  	  	 }
  	  	 
  	  	 $("#portal-system").append(html);
  	  	 
  	 }

    }
});

$(function(){
	
	//退出部分
	$(".system-portal-exit a").click(function(){
		$.ajax({  
		    url:"action/sessionExit.jsp?tokenID="+lilyEns().encode(),
		    type:"post",  
		    success:function(){ 
		    	window.location.replace(Yacon.getRootPath());
		    }
		});
	});
	
/* 	$(window).unload(function(){ 
		$.ajax({  
		    url:"action/sessionExit.jsp",  
		    type:"post",  
		    success:function(){ 
		    }
		});  
	}); 
	
	window.onbeforeunload = function(){
		$.ajax({  
		    url:"action/sessionExit.jsp",  
		    type:"post",  
		    success:function(){ 
		    }
		});  	
	}; */
	
	//用户信息设置
	$("a.system-portal-user").click(function(){
		
		Yacon.showModal({
			url : Yacon.getRootPath()+"/frames/skin_layui/action/user.jsp?tokenID="+lilyEns().encode(),
			width : "400px",
			close : "userChangeSuccess"
		});
		
	});
	
	//密码信息设置
	$("a.system-portal-pwdreset").click(function(){
		
		Yacon.showModal({
			url : Yacon.getRootPath()+"/frames/skin_layui/action/pwd.jsp?tokenID="+lilyEns().encode(),
			width : "700px",
			close : "pwdChangeSuccess"
		});
		
	});
	
	//修改密码弹窗
	$.ajax({
	
	    type: "POST",
	    url: Yacon.getRootPath()+"/portalService?commID=password&tokenID="+lilyEns().encode(),
	    processData: false,
	    async: false,
	    dataType: 'text', 
	    success: function(data){
	    	
	    	if(data == "false"){
	    		Yacon.showModal({
	    			url : Yacon.getRootPath()+"/frames/skin_layui/action/pwd.jsp?tokenID="+lilyEns().encode(),
	    			width : "700px",
	    			height: "200px",
	    			close : "pwdChangeSuccess",
	    			autoClose : false
	    		});
	    	}
	    }
	
	});
		
	
});

function userChangeSuccess(){
	$("a.system-portal-user").parent().removeClass("layui-this");
}

function pwdChangeSuccess(){
	$("a.system-portal-pwdreset").parent().removeClass("layui-this");
}

</script>
<script src="/<%=ESBSetting.getString("appCode")%>/public/js/skin_layui/index.js"></script>